/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package com.aionemu.gameserver.network.aion.serverpackets;

import javolution.util.FastList;

import com.aionemu.gameserver.network.aion.AbstractAionServerPacket;
import com.aionemu.gameserver.network.aion.GameClient;
import com.aionemu.gameserver.questEngine.model.QuestState;

/**
 * @author Mr. Poke
 *
 */
public class SM_QUEST_COMPLETED_LIST extends AbstractAionServerPacket<GameClient>
{
	private FastList<QuestState> questState;
	
	/**
	 * @param questState
	 */
	public SM_QUEST_COMPLETED_LIST(FastList<QuestState> questState)
	{
		this.questState = questState;
	}

	/* (non-Javadoc)
	 * @see com.aionemu.commons.network.netty.packet.AbstractServerPacket#writeImpl(com.aionemu.commons.network.netty.handler.AbstractChannelHandler)
	 */
	@Override
	protected void writeImpl(GameClient client)
	{
		writeH(1);
		writeH(-questState.size() & 0xFFFF);
		for (QuestState qs : questState)
		{
			writeH(qs.getQuestId());
			writeH(0x00);
			writeC(qs.getCompleteCount());
		}
		FastList.recycle(questState);
		questState = null;
	}

}
